package errcode

import (
	"git.myscrm.cn/golang/common/ykerrcode"
)

// 错误码分布由 8 位组成，前 4 位是业务领域，中间 2 位是业务聚合或者模块，最后 2 位是具体场景
// 1 业务领域划分
//
//	2001 => common ，2010=> base ， 2020 => business_opportunity , 2030 => clue, 2040 => market
//
// 2 模块划分
//
//		  2.1 common 对应的模块编号 : 系统 00 验证码 01 dmp 02  导入导出 03
//			 2.2 base 对应的模块编号 : 用户 00, 组织 01 权益 02
//		  2.3 business_opportunity 对应的模块编号: 客户-00，联系人-01，项目-02，招中标-03
//			 2.4 clue 对应的模块编号: 报备-00 线索-01 客户-02
//	   2.4 market 对应的模块编号: 外呼-00, 人群-01, 外呼线索-02, 外呼账号-03
//		  2.5 order 订单：00
const (
	COMMON_ERROR          = 20010000
	COMMON_DATA_NOT_EXIST = 20010001
	COMMON_PARAMS_ERROR   = 20010002
	COMMON_TOKEN_ERROR    = 20010003
	COMMON_DATA_EXIST     = 20010004
	// 20010005 是给前端刷新 token de ，有其他意义，不能用
	COMMON_USER_TOKEN_EXPIRED = 20010005
	COMMON_VERIFY_CODE_ERROR  = 20010007
	COMMON_GET_TENANT_ERROR   = 20010006
	COMMON_TENANT_CODE_ERROR  = 20019999

	COMMON_SMS_CODE_CHECK_CAPTHCHA   = 20010100
	COMMON_SMS_CODE_VERIFY_ERROR     = 20010101
	COMMON_SMS_CODE_MOBILE_NOT_FOUND = 20010102
	COMMON_SMS_CODE_MOBILE_UNVALID   = 20010103
	COMMON_SMS_CODE_MAX_SEND         = 20010104

	COMMON_DMP_INVALID_PAGE_CODE = 20010200
	COMMON_DMP_ISSUE_TOKEN       = 20010201

	ImportIsRunningTask           = 20010300
	ImportFileIdIsNull            = 20010301
	ImportFileIsNotExist          = 20010302
	ImportFileGetDownloadUrlError = 20010303
	ImportFileFormatError         = 20010304
	ImportFileIsEmpty             = 20010305
	ImportFileDataExceedsLimit    = 20010306
	ImportFileGetListError        = 20010307
	ImportFileEditError           = 20010308

	USER_LOGIN_ACCOUNT_LOCKED                   = 20100000
	USER_ACCOUNT_NOT_EXISIT                     = 20100001
	USER_LOGIN_VERIFY_PASSWORD_ERROR            = 20100002
	USER_LOGIN_SAVE_STATUS_ERROR                = 20100003
	USER_LOGIN_SMS_CODE_ERROR                   = 20100004
	USER_RESET_PASSWORD_ERROR                   = 20100005
	USER_LOGIN_NEED_CAPTCHA                     = 20100006
	USER_LOGIN_GET_RESET_PASSWOD_TOKEN          = 20100007
	USER_RESET_PASSWORD_TEMP_TOKEN_ERROR        = 20100008
	USER_SAVE_PASSWORD_ERROR                    = 20100009
	USER_IS_FORBID                              = 20100010
	USER_ISSUE_TOKEN_ERROR                      = 20100011
	USER_SAVE_LOGIN_ERROR                       = 20100012
	USER_LOGIN_NOT_FOUND                        = 20100013
	USER_SAVE_LOGIN_CACHE_ERROR                 = 20100014
	USER_LOGOUT_TOKEN_ERROR                     = 20100015
	USER_LOGOUT_TOKEN_CACHE_ERROR               = 20100016
	USER_GET_LOGIN_ERROR                        = 20100017
	USER_LOGIN_REFRESH_TOKEN_UNEXPIRE_ERROR     = 20100018
	USER_LOGIN_REFRESH_UPDATE_TOKEN_ERROR       = 20100019
	USER_LOGIN_REFRESH_UPDATE_TOKEN_CACHE_ERROR = 20100020
	USER_SYNC_NOT_FOUND_DATA                    = 20100021
	USER_SYNC_DEL_ERROR                         = 20100022
	USER_SYNC_UPDATE_ERROR                      = 20100023
	UserListError                               = 20100024

	// 组织相关
	UserOrgResponseOrgUserError    = 20100100
	UserOrgResponseSubOrgUserError = 20100101

	// 权益部分
	PROFIT_GET_LIST_ERROR = 20100200

	// CustomerNotExistError 客户详情不存在错误码
	CustomerNotExistError = 20200001

	ReportIsExistError = 20300001 //报备已存在

	// 外呼任务
	OutboundTaskCallByApiError            = 20400001
	OutboundTaskCallPhoneError            = 20400002
	OutboundTaskCallRepeatRuleError       = 20400003
	OutboundTaskCallWorkTimeError         = 20400004
	OutboundTaskCallWorkSaveTaskError     = 20400005
	OutboundTaskCallWorkSavePushUserError = 20400006
	OutboundTaskCallGetTaskError          = 20400007
	OutboundTaskCallDelTaskError          = 20400008
	OutboundTaskCallExecuteTaskError      = 20400009
	OutboundTaskGetListError              = 20400010
	OutboundTaskGetLocalListError         = 20400011
	OutboundTaskGetDetailError            = 20400012
	OutboundTaskGetDetailUnStartListError = 20400013
	OutboundTaskGetDetailABError          = 20400014
	OutboundTaskBatchStatusError          = 20400015
	OutboundTaskUpdateIntentionError      = 20400016

	// 外呼账号
	OutboundAccountGetPhoneListError     = 20400300
	OutboundAccountGetSeatListError      = 20400301
	OutboundAccountGetRobotLisError      = 20400302
	OutboundAccountGetDetailError        = 20400303
	OutboundAccountSaveDetailError       = 20400304
	OutboundAccountUnValidCompanyIdError = 20400305
	OutboundAccountHasRunTaskError       = 20400306
	OutboundAccountHasExistError         = 20400307
	OutboundAccountGetExpenseDetailError = 20400308

	// 导出订单
	OrderNoAvailableExportNumError = 20500001 //无可用导出数量

	// 商机部分
	BusinessOpportunityRecordNotFoundError = 20200200 // 记录不存在
	BusinessOpportunityIdNotFoundError     = 20200201 // id 不存在

	// 线索部分
	ClueCustomerRepeatDataError  = 20300200
	ClueCustomerCallRemoteError  = 20300201
	ClueCustomerSaveError        = 20300202
	ClueCustomerSaveIndexError   = 20300203
	ClueCustomerSaveTagError     = 20300204
	ClueCustomerSaveGroupError   = 20300205
	ClueCustomerDeleteError      = 20300206
	ClueCustomerGroupOptionError = 20300207
	ClueCustomerQueryError       = 20300208
)

func init() {
	dict := map[interface{}]string{
		COMMON_ERROR:                                "未知错误",
		COMMON_DATA_NOT_EXIST:                       "记录不存在",
		COMMON_PARAMS_ERROR:                         "请求参数错误",
		COMMON_TOKEN_ERROR:                          "authorization错误",
		COMMON_DATA_EXIST:                           "记录已存在",
		COMMON_VERIFY_CODE_ERROR:                    "验证码错误",
		COMMON_SMS_CODE_CHECK_CAPTHCHA:              "图形验证码错误",
		COMMON_SMS_CODE_VERIFY_ERROR:                "验证码校验失败",
		COMMON_SMS_CODE_MOBILE_NOT_FOUND:            "用户不存在",
		COMMON_SMS_CODE_MOBILE_UNVALID:              "错误的手机号码格式",
		COMMON_SMS_CODE_MAX_SEND:                    "短信验证码发送已经达到上限",
		COMMON_DMP_INVALID_PAGE_CODE:                "无效的页面代码",
		COMMON_DMP_ISSUE_TOKEN:                      "生成 token 失败",
		USER_LOGIN_ACCOUNT_LOCKED:                   "账号已锁定",
		USER_ACCOUNT_NOT_EXISIT:                     "用户不存在",
		USER_LOGIN_VERIFY_PASSWORD_ERROR:            "账号密码错误",
		USER_LOGIN_SAVE_STATUS_ERROR:                "保存登录态失败",
		USER_LOGIN_SMS_CODE_ERROR:                   "验证码错误或者已过期",
		USER_RESET_PASSWORD_ERROR:                   "重设密码失败",
		USER_LOGIN_NEED_CAPTCHA:                     "需要开启验证码",
		USER_LOGIN_GET_RESET_PASSWOD_TOKEN:          "获取重置密码 token 失败",
		USER_RESET_PASSWORD_TEMP_TOKEN_ERROR:        "临时访问凭证不正确或者已失效",
		USER_SAVE_PASSWORD_ERROR:                    "用户设置密码失败",
		USER_IS_FORBID:                              "用户已经被禁用",
		USER_ISSUE_TOKEN_ERROR:                      "颁发用户 token 失败",
		USER_SAVE_LOGIN_ERROR:                       "保存用户登录状态失败",
		USER_LOGIN_NOT_FOUND:                        "获取登录状态失败",
		USER_SAVE_LOGIN_CACHE_ERROR:                 "设置用户登录态缓存失败",
		USER_LOGOUT_TOKEN_ERROR:                     "退出用户登录态失败",
		USER_LOGOUT_TOKEN_CACHE_ERROR:               "退出用户登录态失败（缓存）",
		USER_GET_LOGIN_ERROR:                        "获取登录态失败",
		USER_LOGIN_REFRESH_TOKEN_UNEXPIRE_ERROR:     "refresh token 无效",
		USER_LOGIN_REFRESH_UPDATE_TOKEN_ERROR:       "更新 token 失败",
		USER_LOGIN_REFRESH_UPDATE_TOKEN_CACHE_ERROR: "更新 token 到缓存失败",
		PROFIT_GET_LIST_ERROR:                       "获取权益失败",
		USER_SYNC_NOT_FOUND_DATA:                    "用户同步数据，用户为空",
		USER_SYNC_DEL_ERROR:                         "用户同步，删除用户失败",
		USER_SYNC_UPDATE_ERROR:                      "用户同步，更新数据失败",

		CustomerNotExistError: "客户详情不存在",

		ReportIsExistError: "报备已存在",

		OutboundTaskCallByApiError:            "调用远程接口失败",
		OutboundTaskCallPhoneError:            "线路号码错误",
		OutboundTaskCallRepeatRuleError:       "重拨规则错误",
		OutboundTaskCallWorkTimeError:         "拨号时间段格式错误",
		OutboundTaskCallWorkSaveTaskError:     "保存任务失败",
		OutboundTaskCallWorkSavePushUserError: "保存推送用户失败",
		OutboundTaskCallGetTaskError:          "获取任务失败",
		OutboundTaskCallDelTaskError:          "删除任务失败",
		OutboundTaskCallExecuteTaskError:      "执行任务失败",
		OutboundTaskGetListError:              "获取线路列表失败",
		OutboundTaskGetLocalListError:         "获取本地线路列表失败",
		OutboundTaskGetDetailError:            "获取线路详情失败",
		OutboundTaskGetDetailUnStartListError: "获取详情未完成列表失败",
		OutboundTaskGetDetailABError:          "获取AB总类为空",
		OutboundTaskBatchStatusError:          "批量获取任务状态失败",
		OutboundTaskUpdateIntentionError:      "修改客户意向失败",

		OutboundAccountGetPhoneListError:     "获取线路列表失败",
		OutboundAccountGetSeatListError:      "获取坐席列表失败",
		OutboundAccountGetRobotLisError:      "获取话术列表失败",
		OutboundAccountGetDetailError:        "获取账号详情失败",
		OutboundAccountSaveDetailError:       "设置账号失败",
		OutboundAccountUnValidCompanyIdError: "无效的 Company Id",
		OutboundAccountHasRunTaskError:       "当前有未完成的任务，不能修改 Company Id",
		OutboundAccountHasExistError:         "当前 company id 已经被使用",
		OutboundAccountGetExpenseDetailError: "获取明细详情失败",

		BusinessOpportunityRecordNotFoundError: "详情记录不存在",
		BusinessOpportunityIdNotFoundError:     "Id 缺失",

		ClueCustomerRepeatDataError: "社会信用代码或公司名称已经存在",
		ClueCustomerCallRemoteError: "远程调用获取客户详情失败",
		ClueCustomerSaveError:       "保存客户数据失败",
	}
	ykerrcode.RegisterErrMsg(dict)
}
